package com.example.mercury.my;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatButton;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.mercury.R;
import com.example.mercury.entity.User;
import com.example.mercury.my.exchangerecord.ExChangeRecordActivity;

/**
 * @author 盛守义
 * @createTime 2021/11/3 17:07
 * @projectName TurningCoffee
 * @className SettingsActivity.java
 * @description TODO
 */
public class SettingsActivity extends Activity {
    private LinearLayout ll_userset;
    private ImageView iv_skip, civ_usermsgimg;
    private TextView tv_username, tv_sign;
    private RelativeLayout rl_safe, rl_address, rl_exrecord, rl_private, rl_univer, rl_model, rl_about;
    private AppCompatButton btn_exuser, btn_exit;

    private User user;
    private Intent intent;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_activity_set);
        user = getIntent().getParcelableExtra("userInfo");

        initViews();
        setListener();
    }

    void setUserMsg(User user){
        RequestOptions requestOptions = new RequestOptions().error(R.drawable.avatar).fallback(R.drawable.avatar);
        Glide.with(this).load(user.getData().getUser().getUserImg()).apply(requestOptions).into(civ_usermsgimg);
        tv_username.setText(user.getData().getUser().getUserNickname().trim());
        tv_sign.setText("咖啡豆数： "+user.getData().getUser().getCoffeeBean().toString().trim());

    }

    void setListener(){

    }

    class MyOnClickListener implements View.OnClickListener{
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.iv_skipset:
                    finish();
                    break;
                case R.id.civ_usermsgset:
                    intent = new Intent(SettingsActivity.this, UserMessageActivity.class);
                    intent.putExtra("userInfo", user);
                    startActivity(intent);
                    break;
                case R.id.rl_exrecordset:
                    intent = new Intent(SettingsActivity.this, ExChangeRecordActivity.class);
                    startActivity(intent);
                    break;


                case R.id.btn_exuserset:
                    //切换账户
                    break;
                case R.id.btn_exitset:
                    //退出登录
                    break;
            }
        }
    }

    void initViews(){
        civ_usermsgimg = findViewById(R.id.civ_usermsgset);
        iv_skip = findViewById(R.id.iv_skipset);
        ll_userset = findViewById(R.id.ll_userset);
        tv_sign = findViewById(R.id.tv_signset);
        tv_username = findViewById(R.id.et_usernameset);
        rl_about = findViewById(R.id.rl_aboutset);
        rl_address = findViewById(R.id.rl_addressset);
        rl_univer = findViewById(R.id.rl_universalset);
        rl_safe = findViewById(R.id.rl_safeset);
        rl_exrecord = findViewById(R.id.rl_exrecordset);
        rl_model = findViewById(R.id.rl_modelset);
        rl_private = findViewById(R.id.rl_privateset);
        btn_exuser = findViewById(R.id.btn_exuserset);
        btn_exit = findViewById(R.id.btn_exitset);
    }
}
